package com.hehe.controller;

import com.hehe.POJO.Tb_user;
import com.hehe.Repository.UserRepository;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "")
public class index {

    @Value("${config_file_name}")
    private String config_file_name;

    @Resource
    private UserRepository userRepository;


    @GetMapping(value = "")
    public String index(Model model) {
        System.out.println("访问首页 index 啦 ~ !!!");
        System.out.println("访问首页 index 啦 ~ !!!");
        return "index.html";
    }



    @GetMapping(value = "/test")
    @ResponseBody
    public List<Tb_user> all_user(Model model) {
        System.out.println("TEST-------test -------   SQL   ----  ");
        System.out.println("TEST-------test -------   SQL   ----  ");
        List<Tb_user> allUser = userRepository.findAll();
        return allUser;
    }




}



